package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2022-03-21
 * Time: 21:42
 */
public class Demo6 {
    public static final long count = 10_0000_0000;
    public static void serial() {
        long be = System.currentTimeMillis();
        for (long i = 0; i < count; i++) {

        }
        for (int j = 0; j < count; j++) {

        }
        long en = System.currentTimeMillis();
        System.out.println("消耗时间： "+(en - be)+"ms");
    }
    public static void currency() throws InterruptedException {
        long be = System.currentTimeMillis();
        Thread t1 = new Thread(() -> {

            for (int i = 0; i < count; i++) {

            }

        });
        t1.start();
        Thread t2 = new Thread(() -> {

            for (int j = 0; j < count; j++) {

            }


        });
        t2.start();
        t1.join();
        t2.join();
        long ed = System.currentTimeMillis();
        System.out.println("消耗时间： "+(ed-be)+"ms");
    }

    public static void main(String[] args) throws InterruptedException {
        //serial();
        currency();
    }
}
